﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class VariableScroll : ScrollRectCopy
{
    private List<MessageBaseData> mDatas = new List<MessageBaseData>();

    private bool mInitDone = false;

    protected override void OnScrolling(float curY, bool isUp)
    {
        if (!mInitDone) return;

        MessageItemControl.Instance.Refresh(curY, isUp);
    }

    public void Init()
    {
        MessageItemControl.Instance.SetScroll(this);
    }

    public void AddDatas(List<MessageBaseData> datas)
    {
        if (datas == null) return;
        if (datas.Count == 0) return;

        if (MessageDataControl.Instance.Datas.Count == 0)
        {
            MessageDataControl.Instance.InitDatas(datas);
            MessageItemControl.Instance.InitItems();

            mInitDone = true;
        }
        else
        {
            MessageDataControl.Instance.AddDatasAtTop(datas);
            MessageItemControl.Instance.ReInitItems();
        }
    }
}